<template>
  <m-box title="预警列表" size="small" class="warn-list">
    <m-scroll-board size="small" :row-num="5" :loading="loading" :cols="cols" :datas="tableData" />
  </m-box>
</template>
<script setup>
import http from '@/utils/request'
import moment from 'moment'
import { onMounted } from 'vue'

const cols = ref([
  { width: 40, title: '序号', type: 'seq', align: 'center' },
  { width: 150, title: '工单号', property: 'MO_CODE' },
  { width: 150, title: '产品编码', property: 'MITEM_CODE' },
  // { width: 150, title: '任务单号', property: 'SCHE_NO' },
  { width: 150, title: '当前工序', property: 'STATION_CODE' },
  { width: 150, title: '未完工数量', property: 'UNFINISHED_QTY' },
  {
    width: 150,
    title: '计划完工时间',
    property: 'DATETIME_PLAN_END',
    formatter: ({ value }) => {
      return value ? moment(value).format('YYYY-MM-DD') : value
    }
  }
])
const tableData = ref([])
const loading = ref(false)

const getData = async () => {
  loading.value = true
  try {
    const res = await http.get('/v1/kanban/getMOEarlyWarningReport')
    tableData.value = res.data
  } catch (e) {
    console.error(e)
  } finally {
    loading.value = false
  }
}

function init() {
  getData()
}
onMounted(() => {
  init()
})
</script>
<style lang="less" scoped></style>
